//
//  ChatManager.m
//  SmartTalk
//
//  Created by 陈勃 on 14-12-30.
//  Copyright (c) 2014年 gameabc. All rights reserved.
//

#import "ChatManager.h"
#import "UserCmdProcessor.h"
#import "ChatCmdProcessor.h"
#import "NetWorkManager.h"
@implementation ChatManager
SYNTHESIZE_SINGLETON_FOR_CLASS(ChatManager)

-(void)loginwith:(NSString *)name pwd:(NSString *)pwd callback:(void(^) (NSDictionary*))resp
{
    UserCmdProcessor *loginprocessor = [[UserCmdProcessor alloc] init];
    [loginprocessor loginWith:name pwd:pwd callback:^(CmdProcessor *processor) {
        int userid = [[processor.rspDict objectForKey:@"userid"] intValue];
        [NetWorkManager sharedInstance].senderid = userid;
        NSMutableDictionary *resDic = [NSMutableDictionary dictionaryWithDictionary:processor.rspDict];
        [resDic setObject:@(processor.rspcode) forKey:KEY_RESULT_CODE];
        resp(resDic);
    }];
    [[NetWorkManager sharedInstance] excuteCmd:loginprocessor];
}

-(void)loadFriendList:(int)status callback:(void(^) (NSDictionary*))resp
{
    UserCmdProcessor *loginprocessor = [[UserCmdProcessor alloc] init];
    [loginprocessor getFriendList:status callback:^(CmdProcessor *processor) {
        NSMutableDictionary *resDic = [NSMutableDictionary dictionaryWithDictionary:processor.rspDict];
        [resDic setObject:@(processor.rspcode) forKey:KEY_RESULT_CODE];
        resp(resDic);
    }];
    [[NetWorkManager sharedInstance] excuteCmd:loginprocessor];
}

-(void)sendMsg:(NSDictionary *)msginfo toid:(NSInteger)touserid callback:(void(^) (NSDictionary*))resp
{
    ChatCmdProcessor *chatprocessor = [ChatCmdProcessor sendContent:msginfo toid:touserid callback:^(CmdProcessor *processor) {
        
    }];
    [[NetWorkManager sharedInstance] excuteCmd:chatprocessor];
}
@end
